import { UserLayout, BasicLayout, BlankLayout, PageView, RouteView } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

// ---------- 动态路由总的配置开始处理 ---------- sssstart

// TO-DO-1: 待处理，此处需要定义一个基本的可用于动态生成完整路由的结构
// created: 2021-01-12

let seniorLayerRouter = {
  // 1 - 首页参数设置处理
  index:{
    name: 'Workplace'
  },
  // 2 - 二级及以下参数的设置处理
  children:[
    {
      name: 'Workplace',
      lastLayer: true 
    },
    {
      name: 'Workplace',
      lastLayer: false,
      children:[
        {
          name: '',
          lastLayer: true,
        },
        {
          name: '',
          lastLayer: false
        }
      ]
    }
  ]
}

/**
 * <routerConfig> 完整路由示例
 * 此处无首页单独的页面，我们配置重定向(redirect)到其它页面作为首页路由展示的页面
 * 可配置一级目录，二级目录，三级目录....不断的嵌套配置即可实现多级目录的设置
 * modify by hexunjian at 2021-02-01
 * 
 */
let routerConfig = {
  path: '/',                         // 根目录（主页）  默认 /                      禁止修改
  name: 'index',                     // 主页名称索引    默认 index                  禁止修改
  component: BasicLayout,            // 组件            默认 BasicLayout            禁止修改
  meta: { title: '首页' },           // meta 对象       meta.title=>默认 menu.home  禁止修改
  redirect: '/home/index',           // 重定向路由地址   <选用> 首页重定向到其它页面的需求可以设置此配置
  children: [
    {
      path: '/home/index',
      name: 'index',
      component: () => import('@/views/home/index'),
      meta: {
        title: '首页',
        icon: 'user',
        permission: ['home'],
      }
    },
    
    // 身份认证服务: < 客户端 认证资源  API资源  API范围 > 
    {
      path: '/identity/index',
      name: 'base',
      component: RouteView,
      redirect: '/identity/clients',
      meta: {
        title: '身份认证服务',
        icon: 'user',
        permission: ['identity'],
      },
      children: [
        {
          path: '/identity/clients',
          name: 'Clients',
          component: () => import('@/views/identity/clients'),
          meta: {
            title: '客户端',
            keepAlive: true,
            icon: 'user',
            permission: ['identity'],
            index: 1,
            name: 'clients',
          }
        },
        {
          path: '/identity/identity',
          name: 'Identity',
          component: () => import('@/views/identity/identity'),
          meta: {
            title: '认证资源',
            keepAlive: true,
            icon: 'user',
            permission: ['identity'],
            index: 2,
            name: 'identity',
          }
        },
        {
          path: '/identity/apiresources',
          name: 'Apiresources',
          component: () => import('@/views/identity/apiresources'),
          meta: {
            title: 'API 资源',
            keepAlive: true,
            icon: 'user',
            permission: ['identity'],
            index: 1,
            name: 'apiresources',
          }
        },
        {
          path: '/identity/apiscopes',
          name: 'Apiscopes',
          component: () => import('@/views/identity/apiscopes'),
          meta: {
            title: 'API 范围',
            keepAlive: true,
            icon: 'user',
            permission: ['identity'],
            index: 1,
            name: 'apiscopes',
          }
        }
      ]
    }
  ]     
}

// ---------- 动态路由总的配置结束处理 ---------- eeeeeend


// 此处路由集成
export const asyncRouterMap = [
  routerConfig,
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        // component: undefined
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
